//json

let name = "李四"
let age = 18
let isstu = true
let birth = new Date("1985-3-15 08:00:00")

//let json = {"name": name, "age": age, "isstu": isstu, "birth": birth}

//对象
let json = {name, age, isstu, birth}
console.log(json.name)
console.log(json.age)

//json字符串 string
let jstr = JSON.stringify(json)
console.log(jstr)
console.log(typeof (json))


//原始的json字符串
let json1 = '{"name":name,"age":age,"isstu":isstu,"birth":birth}'
console.log(json1)

//将json字符串转换为对象
let u1 = JSON.parse(json1)
console.log(u1.name)
console.log(u1.birth.toLocaleString())
console.log(new Date(u1.birth).getFullYear())
console.log(typeof (u1.birth))

//使用JSON stringify() 方法快速建立json字符
let json2 = JSON.stringify({name, age, isstu, birth})
console.log(json2)
let u2 = JSON.parse(json2)
console.log(u2.name)
console.log(u2.birth.toLocaleString())
console.log(new Date(u2.birth).getFullYear())
let b = new Date(u2.birth)
console.log(b.toLocaleString())
console.log(typeof (u2.birth))


